package mytest.wd3;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import pojo.Brand;

import java.sql.Array;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;

public class Test_10 {
    private static final List<String> achieveTypeList = Arrays.asList("ACHIEVE_REGISTER", "ACHIEVE_APPLY", "ACHIEVE_LOAN");

    private static final Map<String, String> urlMap = new HashMap<String, String>() {{
        put("ACHIEVE_REGISTER", "zzApiUrlApi14");
        put("ACHIEVE_APPLY", "zzApiUrlApi15");
        put("ACHIEVE_LOAN", "zzApiUrlApi16");
    }};

    private static final Map<String, BiConsumer<List<Map<String, Object>>, String>> handlerMap = new HashMap<String, BiConsumer<List<Map<String, Object>>, String>>() {{
        put("ACHIEVE_REGISTER", (requestList, dateStr) -> handleRegister(requestList, dateStr));
    }};

    private static void handleRegister(List<Map<String, Object>> requestList, String dateStr) throws RuntimeException {
        try {
            int i = 1/0;
            System.out.println(new Gson().toJson(requestList));
            System.out.println(dateStr);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {

        try {
            List<Map<String, Object>> responseList = new ArrayList<>();
            HashMap<String, Object> map = new HashMap<>();
            map.put("a", 1);
            responseList.add(map);
            handlerMap.get("ACHIEVE_REGISTER").accept(responseList, "2024-10-10");
        } catch (Exception e) {
            System.out.println(11);
        }
    }
}
